home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / rpclib / getrpcport.c < prev    next >
C/C++ Source or Header  |  1994-03-09  |  2KB  |  67 lines

  1. /*
  2.  * $Id: getrpcport.c,v 1.2 1993/11/10 02:06:35 jraja Exp $
  3.  *
  4.  * $Log: getrpcport.c,v $
  5.  * Revision 1.2  1993/11/10  02:06:35  jraja
  6.  * ANSI Prototypes, Fixed includes.
  7.  *
  8.  */
  9. /* @(#)getrpcport.c    2.1 88/07/29 4.0 RPCSRC */
  10. #if !defined(lint) && defined(SCCSIDS)
  11. static  char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
  12. #endif
  13. /*
  14.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  15.  * unrestricted use provided that this legend is included on all tape
  16.  * media and as a part of the software program in whole or part.  Users
  17.  * may copy or modify Sun RPC without charge, but are not authorized
  18.  * to license or distribute it to anyone else except as part of a product or
  19.  * program developed by the user.
  20.  * 
  21.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  22.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  23.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  24.  * 
  25.  * Sun RPC is provided with no support and without any obligation on the
  26.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  27.  * modification or enhancement.
  28.  * 
  29.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  30.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  31.  * OR ANY PART THEREOF.
  32.  * 
  33.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  34.  * or profits or other special, indirect and consequential damages, even if
  35.  * Sun has been advised of the possibility of such damages.
  36.  * 
  37.  * Sun Microsystems, Inc.
  38.  * 2550 Garcia Avenue
  39.  * Mountain View, California  94043
  40.  */
  41.  
  42. /*
  43.  * Copyright (c) 1985 by Sun Microsystems, Inc.
  44.  */
  45.  
  46. #include <sys/param.h>
  47. #include <stdio.h>
  48. #include <rpc/rpc.h>
  49. #include <rpc/pmap_clnt.h>
  50. #include <netdb.h>
  51. #include <sys/socket.h>
  52.  
  53. int
  54. getrpcport(char *host, u_long prognum, u_long versnum, u_long proto)
  55. {
  56.     struct sockaddr_in addr;
  57.     struct hostent *hp;
  58.  
  59.     if ((hp = gethostbyname(host)) == NULL)
  60.         return (0);
  61.     bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length);
  62.     addr.sin_family = AF_INET;
  63.     addr.sin_port =  0;
  64.     return (pmap_getport(&addr, prognum, versnum, proto));
  65. }
  66.  
  67.